package com.itheima.mall.service.smsService;

import com.itheima.pojo.sms.SmsHomeBrand;
import com.itheima.mall.commons.PageResult;
import com.itheima.mall.commons.R;
import com.itheima.mall.service.smsService.SmsHomeBrandServiceApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SmsHomeBrandService {

    @DubboReference
    private SmsHomeBrandServiceApi smsHomeBrandServiceApi;
    /**
     * 添加首页推荐品牌
     *homeBrandList
     */
    public void create(List<SmsHomeBrand> homeBrandList) {
        for (SmsHomeBrand smsHomeBrand : homeBrandList) {
            smsHomeBrandServiceApi.create(smsHomeBrand);
        }
    }

    /**
     * 批量删除推荐品牌
     *ids
     */
    public void deleteBrand(List<Long> ids) {
        smsHomeBrandServiceApi.deleteBrand(ids);
    }

    /**
     * 分页查询品牌推荐
     * pageNum pageSize brandName recommendStatus
     */
    public R getBrandByPage(Integer pageNum, Integer pageSize, String brandName, Integer recommendStatus) {
        PageResult<SmsHomeBrand> res = smsHomeBrandServiceApi.getBrandByPage(brandName,recommendStatus,pageNum, pageSize);
        return R.ok(res);
    }

    /**
     * 批量修改推荐品牌状态
     * ids recommendStatus
     */
    public void updateBrand(List<Long> ids, Integer recommendStatus) {
        smsHomeBrandServiceApi.updateBrand(ids,recommendStatus);
    }
    /**
     * 修改推荐品牌排序
     *id sort
     */
    public void updateSortBrand(Long id, Integer sort) {
        smsHomeBrandServiceApi.updateSortBrand(id,sort);
    }
}
